<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/10/17
 * Time: 15:00
 */

namespace app\common\controller;

use think\facade\Request;
use think\Loader;

class AddonsPlatform extends AddonsBase
{
    protected $platform;

    public function initialize()
    {
        parent::initialize();
        //判断是否传参平台类型和平台ID
        $t = Request::param('t');//平台类型
        $p = Request::param('p');//平台ID
        if (!$p || !$t) {
            if ($this->isAjax) {
                $this->results(['code' => 4001, 'msg' => '系统错误', 'data' => '']);
            }
            $this->error('参数错误');
        }
        $_controller = Loader::parseName($t, 1);
        $class = "app\\common\\controller\\platform\\{$_controller}";
        $class = new $class($p);
        $this->platform = $class->init($p);
        if (!$this->platform) {
            $this->error('未找到平台','','','-1');
        }
    }
}